
const { ccclass, property } = cc._decorator;

import YanYing from "./YanYing";
import YanXian from "./YanXian";
@ccclass
export default class StepFive extends cc.Component {
    //触摸区域
    @property(cc.Node)
    bg: cc.Node = null;
    //第五步
    //眼影
    @property(YanYing)
    YanYing: YanYing = null;
    //眼线
    @property(YanXian)
    YanXian: YanXian = null;

    _point = 1;
    onLoad() {
        this.bg.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
        this.bg.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
        this.bg.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
    };

    onTouchStart(event) {
        switch (this._point) {
            case 1:
                this.YanYing._touchStart(event);
                break;
            case 2:
                this.YanXian._touchStart(event);
                break;
        }
    };

    onTouchMove(event) {
        switch (this._point) {
            case 1:
                this.YanYing._touchMove(event);
                break;
            case 2:
                this.YanXian._touchMove(event);
                break;
        }
    };

    onTouchEnd(event) {
        switch (this._point) {
            case 1:
                this.YanYing._touchEnd(event);
                break;
            case 2:
                this.YanXian._touchEnd(event);
                break;
        }
    };

    //更新步骤
    updatePoint(point: number) {
        this._point = point;
        this.YanYing.node.active = point == 1;
        this.YanXian.node.active = point == 2;
        switch (point) {
            case 1:
                this.YanYing.initData();
                break;
            case 2:
                this.YanXian.initData();
                break;
        }
    };


}
